#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class Date
{
	friend ostream& operator<<(ostream& out, const Date& d);
public:
	Date(int year = 2020, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	int GetMonthDay(int year, int month)
	{
		static int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		int day = arr[month];
		if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
		{
			day++;
		}
		return day;
	}
	int GetMonth(int year,int day)
	{
		int month = 1;
		while (day > GetMonthDay(year, month))
		{
			day -= GetMonthDay(year, month);
			month++;
			if (month > 12)
			{
				year++;
			}
		}
		return month;
	}
	int Getday(int year, int day)
	{
		int month = 1;
		while (day > GetMonthDay(year, month))
		{
			day -= GetMonthDay(year, month);
			month++;
			if (month > 12)
			{
				year++;
			}
		}
		return day;
	}


private:
	int _year;
	int _month;
	int _day;
};
ostream& operator<<(ostream& out,const Date& d)
{
	if (d._month >= 10 && d._day >= 10)
		out << d._year << "-" << d._month << "-" << d._day;
	if (d._month >= 10 && d._day <  10)
		out << d._year << "-" << d._month << "-0" << d._day;
	if (d._month <  10 && d._day >= 10)
		out << d._year << "-0" << d._month << "-" << d._day ;
	if (d._month < 10 && d._day <  10)
		out << d._year << "-0" << d._month << "-0" << d._day;
	return out;
}
int main()
{
	int y, n;
	while (cin >> y >> n)
	{
		int month = Date().GetMonth(y, n);
		int day = Date().Getday(y, n);
		Date d(y, month, day);
		cout << d << endl;
	}
	return 0;
}